const c = ((t_mod, t_clr, t_clrm) => (key,txt) => (Array.isArray(key)?key[0]:key).split(' ').reduce((a,k,b,x)=>(x = k.split('.'))&&
  (a+"\x1b["+(t_mod.hasOwnProperty(x[0])?t_mod[x[0]]:t_clr.hasOwnProperty(x[0])?''+t_clrm[x[1]]+t_clr[x[0]]:'0')+'m'),'') + (txt ? txt + c`` : ''))(
  { '': 0, reset: 0, bold: 1, dim: 2, italic: 3, underline: 4, blink: 5, inverse: 7, hidden: 8 },
  { black: 0, red: 1, green: 2, yellow: 3, blue: 4, magenta: 5, cyan: 6, white: 7 },
  { [undefined]: 3, bg: 4, light: 9, bglight: 10 }
);

console.log(c("black.light", 'some dim text'));
console.log(c("yellow red.bg", 'yellow and red background'));
console.log(c`red`+ 'template literals supports' + c``);
console.log(`example: ${c`red`}red${c``} ${c`cyan`}cyan${c``}`);